package com.pactera.madp.cp.common.enums;

import com.pactera.madp.cp.service.TaskPubCustService;
import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public enum TaskPubEnum {

    CUST(1, TaskPubCustService.class);

    private Integer type;
    private Class clazz;

    public static Class getServiceByType(Integer type) {
        if (type == null) {
            throw new IllegalArgumentException("类型不能为空");
        }
        TaskPubEnum[] values = TaskPubEnum.values();
        for (TaskPubEnum tpEnum : values) {
            if (tpEnum.getType().equals(type)) {
                return tpEnum.getClazz();
            }
        }
        throw new RuntimeException("不存此类型服务");
    }
}
